﻿namespace WizardEngine.Tests.FlowSpecificationTests
{
    using WizardEngine.Core.Specification;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using WizardEngine.Core;
    using Moq;
    using WizardEngine.Tests.Common;

    /// <summary>
    /// Unit tests for <see cref="FlowSpecification{T}" /> class. 
    /// </summary>
    [TestClass]
    public class WhenCorrectSpecificationChecked
    {
        [TestMethod]
        public void GivenSimpleFlow_ShouldValidate()
        {
            var specification = FlowSpecificationFactory.Create<MockFlowState>();
            specification.
                RegisterStep("A").MakeInitial()
                    .ConnectTo(specification.RegisterStep("B"), state => state.Age < 18)
                    .ConnectTo(specification.RegisterStep("C"), state => state.Age >= 18)
                .BindStep("B").ConnectTo(specification.RegisterStep("D"), state => true)
                .BindStep("C").ConnectTo(specification.BindStep("D"), state => true);

            Assert.IsTrue(specification.IsValid);
        }
    }
}
